<template>
    <div>
        <button @click="handleClick">返回</button>
        {{ computedTitle }}
        <button>首页 </button>
    </div>
</template>

<script>
import { computed, getCurrentInstance } from 'vue'

export default {
    props: ['title'],
    // setup() 第一个参数是props对象, 第二个参数对象包含子传父emit,属性透传attrs ,...
    setup({title},{emit}) {
        const computedTitle = computed(() => title + '222');

        const handleClick = () => {
            console.log(instance);
            emit('leftevent', 'aaaa');
        }
        // 获取当前组件的实例
        const instance = getCurrentInstance();
        // 获取当前组件的props
        const props = instance.props;
        const root = instance.root;
        return {
            computedTitle, handleClick
         }
    }
    // 
    // setup(props) {
    //     const computedTitle = computed(()=>props.title+'1111');
    //     return {
    //         computedTitle
    //      }
    // }
}
</script>